<template>
  <h2>基本信息</h2>
  <n-table :single-line="false">
    <thead>
      <tr>
        <th class="tar">医院名称</th>
        <th>{{ hospital.hosname }} | {{ hospital.param?.hostypeName }}</th>
        <th class="tar">医院图标</th>
        <th>
          <n-image width="80" :src="getBase64Image(hospital.logoData)" />
        </th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="tar">医院编码</td>
        <td>{{ hospital.hoscode }}</td>
        <td class="tar">详细地址</td>
        <td>{{ hospital.param?.fullAddress + hospital.address }}</td>
      </tr>
      <tr>
        <td class="tar">坐车路线</td>
        <td colspan="3">{{ hospital.route }}</td>
      </tr>
      <tr>
        <td class="tar">医院简介</td>
        <td colspan="3">{{ hospital.intro }}</td>
      </tr>
    </tbody>
  </n-table>
  <h2>预约规则信息</h2>
  <n-table :single-line="false">
    <tbody>
      <tr>
        <td class="tar">预约周期</td>
        <td>{{ hospital.bookingRule?.cycle }}天</td>
        <td class="tar">放号时间</td>
        <td>{{ hospital.bookingRule?.releaseTime }}</td>
      </tr>
      <tr>
        <td class="tar">挺挂时间</td>
        <td>{{ hospital.bookingRule?.stopTime }}</td>
        <td class="tar">退号时间</td>
        <td>就诊前{{ hospital.bookingRule?.stopTime }}工作日{{ hospital.bookingRule?.quitTime }}前取消</td>
      </tr>
      <tr>
        <td class="tar">预约规则</td>
        <td colspan="3">
          <div v-for="(item, index) in hospital.bookingRule?.rule">{{ index + 1 + '. ' +item }}</div>
        </td>
      </tr>
    </tbody>
  </n-table>
</template>
<script>
export default {
  name: "hospital"
}
</script>
<script setup>
import { getHospitalDetail } from '@/api/hospital'
import { onMounted, ref } from 'vue';

const props = defineProps({
  modelValue: {
    type: Object,
    default: {}
  }
})

const hospital = ref({})

const getBase64Image = (str) => {
  if (str == undefined) {
    return ''
  }
  return 'data:image/jpeg;base64,' + str
}

onMounted(async () => {
  hospital.value = await getHospitalDetail(props.modelValue)
})

</script>
<style scoped lang="less">
.tar {
  text-align: right;
  font-weight: bold;
}
</style>